﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.colorchooser {
    import org.aswing.*;
    import org.aswing.geom.*;

    public class VerticalLayout extends EmptyLayout {

        public static const LEFT:int = 0;
        public static const CENTER:int = 1;
        public static const RIGHT:int = 2;

        private var align:int;
        private var gap:int;

        public function VerticalLayout(_arg1:int=0, _arg2:int=0){
            this.align = _arg1;
            this.gap = _arg2;
        }
        public function setGap(_arg1:int):void{
            this.gap = _arg1;
        }
        public function getGap():int{
            return (this.gap);
        }
        public function setAlign(_arg1:int):void{
            this.align = _arg1;
        }
        public function getAlign():int{
            return (this.align);
        }
        override public function preferredLayoutSize(_arg1:Container):IntDimension{
            var _local7:Component;
            var _local8:IntDimension;
            var _local9:int;
            var _local2:int = _arg1.getComponentCount();
            var _local3:int;
            var _local4:int;
            var _local5:int;
            while (_local5 < _local2) {
                _local7 = _arg1.getComponent(_local5);
                if (_local7.isVisible()){
                    _local8 = _local7.getPreferredSize();
                    _local3 = Math.max(_local3, _local8.width);
                    _local9 = ((_local5 > 0)) ? this.gap : 0;
                    _local4 = (_local4 + (_local8.height + _local9));
                };
                _local5++;
            };
            var _local6:IntDimension = new IntDimension(_local3, _local4);
            return (_local6);
        }
        override public function minimumLayoutSize(_arg1:Container):IntDimension{
            return (_arg1.getInsets().getOutsideSize());
        }
        override public function layoutContainer(_arg1:Container):void{
            var _local11:Component;
            var _local12:IntDimension;
            var _local2:Number = _arg1.getComponentCount();
            var _local3:IntDimension = _arg1.getSize();
            var _local4:Insets = _arg1.getInsets();
            var _local5:IntRectangle = _local4.getInsideBounds(_local3.getBounds());
            var _local6:int = _local5.width;
            var _local7:int = _local5.x;
            var _local8:int = _local5.y;
            var _local9:int = (_local7 + _local6);
            var _local10:int;
            while (_local10 < _local2) {
                _local11 = _arg1.getComponent(_local10);
                if (_local11.isVisible()){
                    _local12 = _local11.getPreferredSize();
                    if (this.align == RIGHT){
                        _local11.setBounds(new IntRectangle((_local9 - _local12.width), _local8, _local12.width, _local12.height));
                    } else {
                        if (this.align == CENTER){
                            _local11.setBounds(new IntRectangle(((_local7 + (_local6 / 2)) - (_local12.width / 2)), _local8, _local12.width, _local12.height));
                        } else {
                            _local11.setBounds(new IntRectangle(_local7, _local8, _local12.width, _local12.height));
                        };
                    };
                    _local8 = (_local8 + (_local12.height + this.gap));
                };
                _local10++;
            };
        }
        override public function getLayoutAlignmentX(_arg1:Container):Number{
            return (0.5);
        }
        override public function getLayoutAlignmentY(_arg1:Container):Number{
            return (0.5);
        }

    }
}//package org.aswing.colorchooser 
